package com.example.ftptest;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;

public class MenuActivity extends Activity {
	
	private String  pass, host, user;
	private int port;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		  Bundle extra= this.getIntent().getExtras();
	        
	        if(extra!=null){
	        	pass = extra.getString("pass");
	        	host = extra.getString("host");
	        	user = extra.getString("user");
	        	port = extra.getInt("port");
	        }
	        
		setContentView(R.layout.activity_menu);
		//upload file from ftp
		View uploadButton = findViewById(R.id.button2);
        uploadButton.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				uploadFTP();
				
			}
		});
        
        
        //exit from ftp
        View exitButton = findViewById(R.id.button4);
        exitButton.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				finish();
			}
		});

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.menu, menu);
		return true;
	}
	
	 protected void uploadFTP() {
			
			Intent uploadIntent = new Intent(this,UploadActivity.class);
			uploadIntent.putExtra("host", host);
			uploadIntent.putExtra("pass", pass);
			uploadIntent.putExtra("port", port);
			uploadIntent.putExtra("user", user);
			startActivity(uploadIntent);
		}

}
